//
//  UIImageView+ACExt.m
//  ACFramework
//
//  Created by caoyq on 2018/5/23.
//

#import "UIImageView+ACExt.h"
#import "UIImageView+WebCache.h"
#import "UIImage+ACExt.h"

@implementation UIImageView (ACExt)

#pragma mark - url图片的加载

- (void)ac_setImageWithURLString: (NSString *)urlString
{
    NSURL *imgURL = [NSURL URLWithString:urlString];
    [self sd_setImageWithURL:imgURL placeholderImage:nil];
}

- (void)ac_setImageWithURLString:(NSString *)urlString placeholderImage: (UIImage *)placeholderImage
{
    NSURL *imgURL = [NSURL URLWithString:urlString];
    [self sd_setImageWithURL:imgURL placeholderImage:placeholderImage];
}

- (void)ac_setCircleImageWithURLString: (NSString *)urlString
{
    NSURL *imgURL = [NSURL URLWithString:urlString];
    [self sd_setImageWithURL:imgURL placeholderImage:nil options:SDWebImageAvoidAutoSetImage completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        image = [image ac_getCircleImage];
        dispatch_async(dispatch_get_main_queue(), ^{
            self.image = image;
            [self setNeedsLayout];
        });
    }];
}

@end
